// pages/signin/signin.js
const db = wx.cloud.database({
  env: "hanfuzhanshi-1gx7izh61688b26c"
})
const _ = db.command
var util = require('../../../utils/time.js');


let app = getApp()
const key = app.globalData.key
import api from "../../../utils/api.js"
import task from "../../../utils/request.js"
Page({

  /**
   * 页面的初始数据
   */
  data: {
    // 日历
    yesdate:''
  },


  activeSign() {
    let that = this
    wx.requestSubscribeMessage({
      tmplIds: ['bRnTQ46RrclaDPUWMWcuViqJmO3vfaolXzT9JVhUGJc'],
      success(res) {
        let calendar1 = that.selectComponent('#calendar1');
        calendar1.activeSign()

      }
    })
  },
  // 签到过

  userlist() {
    wx.cloud.callFunction({
      name: 'userlist',
    }).then(res => {
      this.setData({
        userlist: res.result.data
      })
      console.log(this.data.userlist)
    })
  },

  yesdate() {


    let now = new Date();
    let year = now.getFullYear();
    let month = now.getMonth() + 1 < 10 ? "0" + String(now.getMonth() + 1) : now.getMonth() + 1;
    this.setData({
      year: year,
      month: Number(month),
      isToday: '' + year + month + now.getDate()
    });
    console.log(this.data.isToday)
    let t = wx.getStorageSync("userInfo")
    console.log(t._id)

    if (t._id) {
      api.GET_User2.doc = t._id
      task.Tree_get(api.GET_User2).then(res => {


        this.setData({
          yesdate:  res.sign_data
        })

        console.log(this.data.yesdate)
      })
    }






  },
  // 日历

  onLoad: function (options) {

    this.yesdate()

  },
})